package {
	import flash.display.Sprite;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	public class MoonshineTest extends Sprite {
		private var propertyA:String = "lol";
		private var propertyB:String = "heh";
		private var propertyObject:Object = {"a": propertyA, "b": propertyB};
		private var timer:Timer;
		public function MoonshineTest() {
			graphics.beginFill(0xFF0000);
			graphics.drawRect(50, 50, 100, 100);
		
			trace("Begin constructor!");
			testFunction();
			timer = new Timer(500);
			timer.addEventListener(TimerEvent.TIMER, recurringCall);
			timer.start();
			trace("End constructor!");
		}
		private function testFunction():void {
			var a:int = 123;
			var b:int = 0xDECAF;
			var c:int = a+b;
			trace("testFunction() called, result is "+c+" -_-");
		}
		private function recurringCall(e:TimerEvent):void {
			for (var i:int = 0; i < 100; i++) {
				moreExpensiveCall();
				lessExpensiveCall();
			}
			mostExpensiveCall();
			mouseExpensiveCall();
			
			//trace("Result "+a);
			//trace("Call #"+timer.repeatCount);
		}
		private function moreExpensiveCall():void {
			var n:Number = 0;
			for (var i:int = 0; i < 1000; i++) {
				n += Math.random();
			}
		}
		private function lessExpensiveCall():void {
			var n:Number = 0;
			for (var i:int = 0; i < 250; i++) {
				n += Math.random();
			}
		}
		private function mostExpensiveCall():void {
			var n:Number = 0;
			for (var i:int = 0; i < 5000; i++) {
				n += Math.random();
			}
		}
		private function mouseExpensiveCall():void {
			var m:Number = stage.mouseX/stage.stageWidth > 0.5 ? 1000000 : 0;
			var n:Number = 0;
			for (var i:int = 0; i < m; i++) {
				n += Math.random();
			}
		}
	}
}